/*
 *  math_util.c
 *  PancatLib
 *
 *  Created by Liu Lingguang on 6/4/11.
 *  Copyright 2011 Pancat. All rights reserved.
 *
 */

#include "math_util.h"

int gcd(int a, int b) {
  while (a != b) {
    if (a > b)
      a = a - b;
    else
      b = b - a;
  }
  return a;
}

int gcd_recursive(int a, int b) {
  if (b != 0) {
    return gcd_recursive(b, a % b);
  }
  return a;
}